﻿namespace Hotel.Module.Resources.Models
{
    using System;
    using Entities = Hotel.Module.Resources.DataRepository;

    public class Period: Model.Infrastructure.IDistributedStorageEntity
    {
        /// <summary>
        /// Creates a new Instance of Period according to recived Entity Period instance
        /// </summary>
        /// <param name="entity">Entity Period object from which new Period instance will be created</param>
        public static Period FromEnityModel(Entities.Period entity)
        {
            Period result = new Period();
            if (entity == null)
            {
                return null;
            }
            else
            {
                result.InDate = entity.InDate;
                result.OutDate = entity.OutDate;
                result.OrderID = entity.OrderID;
            }
            return result;
        }
        /// <summary>
        /// In date
        /// </summary>
        public DateTime InDate { get; set; }

        /// <summary>
        /// Out Date
        /// </summary>
        public DateTime OutDate { get; set; }

        /// <summary>
        /// identificational number of order for current period
        /// </summary>
        public int OrderID { get; set; }
        public string PartitionKey { get; set; }
        public string RowKey { get; set; }
        public DateTime Timestamp { get; set; }

        /// <summary>
        /// Assignes to recieved object data from current instnce
        /// </summary>
        /// <param name="obj">Object to which the data of current insctnce will be copied</param>
        public void AssignTo(object obj)
        {
            if (obj is Entities.Period)
            {
                Entities.Period result = obj as Entities.Period;

                result.InDate = InDate;
                result.OutDate = OutDate;
                result.OrderID = OrderID;
                return;
            }

            throw new NotSupportedException();
        }
    }
}
